package pers.zero;

import com.zaxxer.hikari.pool.HikariPool;
import code.whmmm.util.hikari.jdbcpool.JdbcPoolConfig;
import code.whmmm.util.hikari.jdbcpool.JdbcPoolFactory;
import code.whmmm.util.hikari.jdbcpool.SimpleDbUtil;

/**
 * <p><b>
 * 枚举实现 单例模式
 * </b></p>
 * <br/>
 * 创建时间: 2019/9/30 21:45
 *
 * @author Zero
 */
public enum DataSourceDb {

    INSTANCE;

    private final SimpleDbUtil dbUtil;

    DataSourceDb() {
        JdbcPoolConfig conf = new JdbcPoolConfig();
        conf.setMin(1);
        conf.setMax(1);
        conf.setInit(1);
        conf.setUsername("root");
        conf.setPassword("cjy12345");
        conf.setUrl("192.168.0.7:3306");
        conf.setName("data_fetch_test");
        final HikariPool pool = JdbcPoolFactory.createPool(conf);
        dbUtil = new SimpleDbUtil(pool);
    }

    public SimpleDbUtil getInstance() {
        return dbUtil;
    }

}
